<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if(!file_exists('configuration.php')){
	print "The configuration.php file does not exist. 
	Make a copy of the configuration.php.dist file and name it configuration.php. 
	Then this programm will work";
	exit;
}
require_once "configuration.php";
$settingsfile = file_get_contents($settings['settingsfile']);
/** Setting defaults **/
$hideDelayValue = "1000";
$appearStyleValue = "over";
$clipTypeValue = "0";
$clipVerticalValue = false;
$clipHorizontalValue = false;
$clipSpeedValue = "4";
$clipIncrementValue = $clipSpeedValue;
$fadingTypeValue = "0";
$fadingStepsValue = "50";
preg_match_all("/bwtMenu\.(.*)=(.*);/",$settingsfile, $matches, PREG_SET_ORDER);
foreach($matches as $match){
	$varname = $match[1]."Value";
	$$varname = $match[2];
}
if($clipVerticalValue == 'true') $clipTypeValue = 1;
if($clipHorizontalValue == 'true') $clipTypeValue = 2;
if($clipVerticalValue == 'true' && $clipHorizontalValue == 'true') $clipTypeValue = "3";
$clipSpeedValue = $clipIncrementValue;
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>The website MenuBuilder</title>

	<link rel='stylesheet' type='text/css' href='./menufiles/menu.css'>
	<link rel="stylesheet" type="text/css" href="./css/dhtmlXTree.css">
	<link rel="stylesheet" type="text/css" href="./css/Context.css">
	<link rel="stylesheet" type="text/css" href="./css/tabber.css">
	<link rel="stylesheet" type="text/css" href="./plugin/plugin.css">
	
	<script type="text/javascript">
		var tabberOptions = {'onClick':function(){$("plugin").style.display="none";}};
	</script>
	<script type='text/javascript' src='./js/common.js'></script>
	<script type="text/javascript" src="./js/dhtmlXCommon.js"></script>
	<script type="text/javascript" src="./js/dhtmlXTree.js"></script>
	<script type="text/javascript" src="./js/tabber.js"></script>
	<script type="text/javascript" src="./js/layoutfunctions.js"></script>
	<script type='text/javascript' src='./plugin/plugin.js'></script>
	<script type='text/javascript' src='./js/bwtMenu.js'></script>
	<script type='text/javascript' src='./js/menusettingsfunctions.js'></script>
	<script type="text/javascript">
		var menuCurrentId = 'menuitem<?php print isset($_GET['page'])?$_GET['page']:'thisisnoid';?>';
	</script>
	<?php $xajax->printJavascript('./js/','xajax.js');?> 
</head>
<body>
	<div id="menu_test_div" style="width:100%">
		<?php print file_get_contents($settings['menu_structurefile']); ?>
		<script type="text/javascript" src="./menufiles/settings.js"></script>
	</div>
	<div style="clear:both;"></div>
	<table>
		<tr>
			<td valign="top">
				<div style="background-color:#cfc; border: 2px solid #090; padding:10px;">
					<table><tr><td>
					<div id="treeboxbox_tree" style="width:250; height:218;background-color:#f5f5f5;border :1px solid Silver;"></div>
					</td><td>
						id: <span id="activeID"></span><br/>
						name: <input type=text id="newname" onchange="tree.setItemText(tree.getSelectedItemId(),this.value);"/><br/>
						link: <input type=text id="link" onkeyup="aInfo[tree.getSelectedItemId()]['href']=this.value"/><br />
			<a href="javascript:void(0)" onclick="deleteMenu()">Delete</a><br/>
				<input type="text" value="New item" id="newMenuItem">
			<!--<a href="javascript:void(0);" onclick="var d=new Date();var newid=d.valueOf(); tree.insertNewItem(tree.getSelectedItemId(),d.valueOf(),document.getElementById('newMenuItem').value,0,'book.gif','books_open.gif','books_close.gif','SELECT'); newMenuItem(newid); onNodeSelect(newid);">Insert new child item</a> 
			&nbsp;&nbsp;&nbsp;-->
			<a href="javascript:void(0);" onclick="var d=new Date(); var newid=d.valueOf(); tree.insertNewNext(tree.getSelectedItemId(),d.valueOf(),document.getElementById('newMenuItem').value,0,'book.gif','books_open.gif','books_close.gif','SELECT'); newMenuItem(newid); onNodeSelect(newid);">New menu</a><br />
			<button onclick="xajax_create_menu_structurefiles(getXMLtree(), getHTMLtree(), getSettings(), getCSS());">
				<?php print $mb->s['target_save']?'Preview':'Save';?>
			</button><br />
			<?php if($mb->s['target_save'])print'
			<button onclick="xajax_create_menu_targetfiles(getXMLtree(), getHTMLtree(), getSettings(), getCSS());">Save menu</button>';?>
					</td></tr></table>
				</div>
			</td>
			<td>
				<div style="background-color:#ccf; border: 2px solid #009; padding:10px;">
					Menu orientation: <select id="menuOrientation">
						<option value="horizontal">Horizontal</option>
						<option value="vertical">Vertical</option>
					</select><br />
						<script type="text/javascript">
							document.getElementById("menuOrientation").value = '<?php print $mb->ls['menuOrientation'];?>';
						</script><br />
						Submenu indication:
						<select id="submenuIndicatorType">
							<option value="text">Text</option>
							<option value="image">Image</option>
						</select>
						<script type="text/javascript">
							document.getElementById("submenuIndicatorType").value="<?php print $mb->ls['submenuIndicatorType'];?>";
						</script>
						<input type="text" size="7" id="submenuIndicatorVar" value="<?php print $mb->ls['submenuIndicatorVar'];?>"/><br />
						<input type="checkbox" id="menuCurrentStyle" <?php print $mb->ls['menuCurrentStyle']?'checked':'';?> />Special style for current menu<br />
					Hide delay <input type="text" size="3" id="hideDelay" value="<?php print $hideDelayValue;?>">ms<br />
					Show <select id="appearStyle">
						<option value="over">On Mouseover</option>
						<option value="click">On click</option>
					</select><br />
						<script type="text/javascript">
							document.getElementById("appearStyle").value = <?php print $appearStyleValue;?>;
						</script>
					<br />
					<div style="border: 1px dotted #777; background-color:#aac;padding:10px;">
						<b><u>Animation</u></b><br />
						Clip: <select id="clipType">
							<option value="0">No</option>
							<option value="1">Vertical</option>
							<option value="2">Horizontal</option>
							<option value="3">Both</option>
						</select>
						<select id="clipSpeed">
							<option value="2">Slow</option>
							<option value="4">Normal</option>
							<option value="6">Fast</option>
						</select><br />
						<script type="text/javascript">
							document.getElementById("clipType").value = <?php print $clipTypeValue;?>;
							document.getElementById("clipSpeed").value = <?php print $clipSpeedValue;?>;
						</script>
						Fading:<select id="fadingType">
							<option value="0">No</option>
							<option value="1">Fade in</option>
							<!--<option value="1">Fade out</option>-->
							<!--<option value="2">Both</option>-->
						</select>
						<select id="fadingSteps">
							<option value="80">Slow</option>
							<option value="50">Normal</option>
							<option value="20">Quick</option>
						</select>
						<script type="text/javascript">
							document.getElementById("fadingType").value = <?php print $fadingTypeValue;?>;
							document.getElementById("fadingSteps").value = <?php print $fadingStepsValue;?>;
						</script>
					</div><!-- Animation -->
				</div><!-- settings -->
			</td>
		</tr>
		<tr><td colspan=2>
			<div style="width:100%;">
				<div class="tabber">
					<div class="tabbertab" title="Main menu">
						<?php print $mb->getLayoutControls('main', false, true);?>
					</div>
					<div class="tabbertab" title="Main menu active">
						<?php print $mb->getLayoutControls('activemain',true);?>
					</div>
					<?php
					if($mb->ls['menuCurrentStyle']){
						print '
						<div class="tabbertab" title="Main menu current">
							'.$mb->getLayoutControls('currentmain',true).'
						</div>';
					}?>
					<div class="tabbertab" title="Submenu">
						<?php print $mb->getLayoutControls('sub',false);?>
					</div>
					<div class="tabbertab" title="Submenu active">
						<?php print $mb->getLayoutControls('activesub',true);?>
					</div>
					<?php
					if($mb->ls['menuCurrentStyle']){
						print '
						<div class="tabbertab" title="Submenu current">
							'.$mb->getLayoutControls('currentsub',true).'
						</div>';
					}?>
				</div>
			</div>
</table>
<script type="text/javascript" src="./js/treefunctions.js"></script>
<div id="plugin" onmousedown="HSVslide('drag','plugin',event)" style="TOP: 140px; LEFT: 430px; Z-INDEX: 2000;display:none;">
 <div id="plugHEX" onmousedown="stop=0; setTimeout('stop=1',100);">F1FFCC</div><div id="plugCLOSE" onmousedown="toggle('plugin')">X</div><br>
 <div id="SV" onmousedown="HSVslide('SVslide','plugin',event)" title="Saturation + Value">
  <div id="SVslide" style="TOP: -4px; LEFT: -4px;"><br /></div>
 </div>
 <form id="H" onmousedown="HSVslide('Hslide','plugin',event)" title="Hue">
  <div id="Hslide" style="TOP: -7px; LEFT: -8px;"><br /></div>
  <div id="Hmodel"></div>
 </form>
</div>
<script type="text/javascript">
function colorpick(id){
	colorTargetId = id;
	var s = $(id).value;
	var intString="0123456789abcdefABCDEF";
	var colorValue = '';
	for(var i=0;i<s.length;i++)if(intString.indexOf(s.charAt(i))!=-1)colorValue+=s.charAt(i);
	if(colorValue.length==3){
		colorValue=colorValue.charAt(0)+colorValue.charAt(0)+colorValue.charAt(1)+colorValue.charAt(1)+colorValue.charAt(2)+colorValue.charAt(2);
	}
	//alert(colorValue);
	if(colorValue.length==6)updateH(colorValue); //not working yet, but will be (can only be hex value without #)
	$('plugin').style.display = 'block';
}
var colorTargetId = 'idontexistasId';
function mkColor(v) {
	var target = document.getElementById(colorTargetId);
	if(target){
		target.style.background='#'+v;
		if(target.value) target.value = '#'+v;
	}
}

loadSV(); updateH('FF0000');

</script>

</body>
</html>
